const http = require("http");
const app = require("./module/router")
const ejs = require("ejs");

// 注册web服务
http.createServer(app).listen(3000);

console.log('Server running at http://127.0.0.1:3000/');

app.static("static");  // 修改默认静态web目录

// 配置路由
app.get("/", function(req, res) {
  res.send("首页");
})

app.get("/login", function(req, res) {
  ejs.renderFile("./views/form.ejs", {}, (error, data) => {
    res.send(data);
  })
})

app.post("/doLogin", function(req, res) {
  console.log(req.body);
  res.send(req.body);
})